package ubc.cs.cpsc210.sustainabilityapp.model;

import java.util.Comparator;

public class CompareFoodServiceLocationssByRating implements Comparator<FoodService> {
        
    public int compare(FoodService r1, FoodService r2) {
        double d1 = r1.getRating();
        double d2 = r2.getRating();
        
        int c = -1 * Double.compare(d1, d2);
        if (c == 0) {
            // last resort comparison:  by name
            c = r1.compareTo(r2);
        }
        return c;
    }
    
}
